<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="../static/css/base.css"/>
    <link rel="stylesheet" href="../static/css/index.css">

</head>
<body>

<div class="panel panel-default">
    <!-- Default panel contents -->
    <div class="panel-heading">历史订单</div>

    <!-- Table -->

    <table class="table">

    </table>
</div>

<script src="../static/bootstrap/js/jquery-3.3.1.js"></script>
<script>
    $(function () {
        alert(11)
        var username = "${user.userName}"
        $.ajax({
            url:"http://localhost:8080/getOrderInfo",
            data:"userName=" + username,
            success:function (data) {
                var html = "<tr>\n" +
                    "            <td>订单状态</td>\n" +
                    "            <td>订单号</td>\n" +
                    "            <td>订单时间</td>\n" +
                    "            <td>入住时间</td>\n" +
                    "            <td>离店时间</td>\n" +
                    "            <td>酒店名称</td>\n" +
                    "            <td>房间类型</td>\n" +
                    "            <td>房间数目</td>\n" +
                    "            <td>房间单价</td>\n" +
                    "            <td>应付金额</td>\n" +
                    "            <td>会员折扣</td>\n" +
                    "            <td>实付金额</td>\n" +
                    "            <td>快速预订</td>\n" +
                    "        </tr>";
                var status;
                for(var i = 0;i < data.length;i++){
                    if(data[i].orderStatus == 1){
                        status = "支付失败"
                    }
                    else if(data[i].orderStatus == 0){
                        status = "支付成功"
                    }
                    else if(data[i].orderStatus == 2){
                        status = "未完成支付"
                    }
                    html = html + " <tr>\n" +
                        "            <td>"+status+"</td>\n" +
                        "            <td>"+data[i].orderNum+"td>\n" +
                        "            <td>"+data[i].orderTime+"</td>\n" +
                        "            <td>"+data[i].moveIn+"</td>\n" +
                        "            <td>"+data[i].moveOut+"</td>\n" +
                        "            <td>"+data[i].hotelName+"</td>\n" +
                        "            <td>"+data[i].roomType+"</td>\n" +
                        "            <td>"+data[i].rommNum+"</td>\n" +
                        "            <td>"+data[i].roomCharge+"</td>\n" +
                        "            <td>"+data[i].totalMoney+"</td>\n" +
                        "            <td>"+data[i].discount+"</td>\n" +
                        "            <td>"+data[i].realMoney+"</td>\n" +
                    "            <td><button type=\"button\" class=\"btn btn-success\">快速预订</button>\n" +
                    "            </td>\n" +
                    "        </tr>"
                }
                $(".table").html(html)
            }

        })
    })
</script>
</body>
</html>